<?php

namespace catchAdmin\pc\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\pc\model\SysSet as SysSetModel;
use think\Response;

class SysSet extends CatchController
{

    protected $sysSetModel;


    /**
     *
     * @time 2025/08/05 15:17
     * @param SysSetModel $sysSetModel
     * @return mixed
     */
    public function __construct(SysSetModel $sysSetModel)
    {
        $this->sysSetModel = $sysSetModel;
    }


    /**
     *
     * @time 2025/08/05 15:17
     * @return Response
     */
    public function index(): Response
    {
        return CatchResponse::paginate($this->sysSetModel->getList());
    }


    /**
     *
     * @time 2025/08/05 15:17
     * @param Request $request
     * @return Response
     */
    public function save(Request $request): Response
    {
        return CatchResponse::success($this->sysSetModel->storeBy($request->post()));
    }


    /**
     *
     * @time 2025/08/05 15:17
     * @param $id
     * @return Response
     */
    public function read($id): Response
    {
        return CatchResponse::success($this->sysSetModel->findBy($id));
    }


    /**
     *
     * @time 2025/08/05 15:17
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request): Response
    {
        return CatchResponse::success($this->sysSetModel->updateBy($id, $request->post()));
    }


    /**
     *
     * @time 2025/08/05 15:17
     * @param $id
     * @return Response
     */
    public function delete($id): Response
    {
        return CatchResponse::success($this->sysSetModel->deleteBy($id));
    }
}
